from typing import List
import numpy as np
# import cworld.cworld as cworld
from .cworld import reset,step

# import os
# from ctypes import *
# cworld = CDLL(os.path.join(os.path.dirname(__file__), "c_world.cpython-38-x86_64-linux-gnu.so"))

class Enveronment:
    ACT_DIM=7
    OBS_DIM=8
    def reset(self,ran_seed:int,sb_num:int)->list:
        '''
        重置环境，并输出初始状态
        '''
        sb_list=reset(ran_seed,sb_num)
        return [sb_list[0].get_obs(),sb_list[1].get_obs()]



    def step(self,actions):
        '''
        智能体真正执行动作。然后环境更新状态，并反馈一个奖励。
        done:1:0win;-1:1win
        '''
        sb_list=cworld.step(actions)

        done=sb_list[0].get_done()
        if sb_list[1].get_done()==1:
            done=-1

        return [sb_list[0].get_obs(),sb_list[1].get_obs()],[sb_list[0].get_reward(),sb_list[1].get_reward()],done

